﻿using Shinva.LADModel.Abstractions;
using Shinva.Variables.Interface;
using Shinva.Variables.Models;
using Shinva.Variables.Type.bit;
using Shinva.Variables.Type.time;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shinva.LADModel.Type.TimerOperations
{
    public class TON:ElementNodeBase
    {
        public PlcTime PT { get; set; }
        public PlcTime ET { get; set; }
        public string instanceName { get; set; }

        public override PlcBool EN
        {
            get
            {
                
                return eno;
            }
            set
            {
                eno = value;
            }
        }
        public override PlcBool ENO
        {
            get
            {

                eno.Value = EN.Value;
                return eno;
            }
            set
            {
                eno = value;
            }
        }

        public TON()
        {
            Name = "TON";
            variableTableInterface.AddVariable("ET", StorageType.Output);
            variableTableInterface.AddVariable("PT", StorageType.Input);
            PT = variableTableInterface.GetVariableValue<PlcTime>("PT");
            ET = variableTableInterface.GetVariableValue<PlcTime>("ET");
        }
        public override IPlcMember GetInterfaceVariableByName(string name)
        {
            if (name == "IN") return en;
            else if (name == "Q") return ENO;
            else return variableTableInterface.GetVariableValue<IPlcMember>(name);
        }
    }
}
